package com.booking.springrestful.controller;


import com.booking.springrestful.domain.Announcements;
import com.booking.springrestful.resp.ResponseResult;
import com.booking.springrestful.service.AnnouncementsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/announce")
public class announceController {

    @Resource
    private AnnouncementsService announcementsService;

    //发布公告
    @PostMapping
    private ResponseResult announce(@RequestBody Announcements announcement) {
        announcementsService.announce(announcement);
        return ResponseResult.success("发布成功");
    }


    @GetMapping("/get")
    private ResponseResult<List<Announcements>> getAnnouncements() {
        List<Announcements> list=announcementsService.getAnnouncements();
        return ResponseResult.success(list);
    }
}
